package main

import (
	"fmt"
)

func writeData(data chan int)  {
	for i:=1;i<=2000;i++ {
		data <- i
	}
	close(data)
}

func writeRes(data chan int,res chan map[int]int,nums chan bool) {
	for {
		num ,ok := <-data
		if !ok {
			break
		}
		var result int = 0
		for i:=0;i<=num;i++ {
			result += i
		}
		in := make(map[int]int)
		in[num] = result
		res <- in
	}
	nums <- true
}

func main()  {
	
	data := make(chan int,100)
	res := make(chan map[int]int,2000)
	nums := make(chan bool,8)

	go writeData(data)

	for i:=0;i<8;i++ {
		go writeRes(data,res,nums)
	}

	go func ()  {
		for i:=0;i<8;i++ {
			<-nums
		}
		close(res)
	}()
	
	for {
		m,ok := <- res
		if !ok {
			break
		}
		fmt.Println(m)
	}

}